<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include  file="/jsps/common/taglibs.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title></title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	
	<link rel="stylesheet" type="text/css" href="<c:url value="/css/list.css"/>">
	<script type="text/javascript">
	    function mend(name){
	        location.href="<c:url value="userMgr?act=for_update&user_name="/>"+name;
	    }
	    function del(name){
	        if(window.confirm("确定要删除[ "+name+" ]会员的信息吗?")){
	            location.href="<c:url value="userMgr?act=delete&user_name="/>"+name;
	        }
	    }
	    function setStatus(name,no){
	        location.href="<c:url value="userMgr?act=setStatus&user_name="/>"+name+"&status="+no;
	        
	    }
	    
	     //pageno 指定页码数
         function doQuery(pageno)
         {
           if(pageno<1 || pageno>${page.totalPageNum})
           {
              alert("页号超出范围，有效范围：[1-"+${page.totalPageNum}+"]!");
              document.getElementById("pageNo").select();
              return "";
           } 
           //location.href="<c:url value="/userMgr?act=for_list"/>"+"&page_no="+pageno;
            document.forms[0].page_no.value=pageno;
            document.forms[0].submit();
            
         }
         function doQuery2(){
           
           var pageNo=document.getElementById("pageNo").value;
           doQuery(pageNo);
           
         }
         //控制键盘输入
         function onlynumber(){
		   if(event.keyCode==13)
			 return true;
		   if(event.keyCode<48||event.keyCode>57)
		   {
			 event.keyCode=0;
			 event.returnValue=false;
		   }
		   event.returnValue=true;
	     }
         
	</script>
	
  </head>
  
  <body>
      <div class="wrapper_div">
          <span class="title">查询会员信息</span>
          <div class="wrapper_div">
              <form class="content_form" action="<c:url value="/userMgr"/>">
                  <input type="hidden" name="act" value="for_list"/>
                  <input type="hidden" name="page_no" value=""/>
                  <span>性别:</span>
                  <select name="sex">
                      <option value="">=请选择=</option>
                      <option value="0" <c:if test="${param.sex==0}">selected=selected</c:if> >男</option>
                      <option value="1" <c:if test="${param.sex==1}">selected=selected</c:if> >女</option>
                  </select>
                  &nbsp;
                  <span>状态:</span>
                  <select name="status">
                      <option value="">=请选择=</option>
                      <option value="0" <c:if test="${param.status==0}">selected=selected</c:if> >未冻结</option>
                      <option value="1" <c:if test="${param.status==1}">selected=selected</c:if> >冻结</option>
                  </select>
                  <input type="submit" value="查 询"/>
              </form>
          </div>
      </div>
      <hr/>
      <div class="wrapper_div">
          <table class="listtable">
              <thead>
                  <th>用户名</th>
                  <th>密码</th>
                  <th>真实姓名</th>
                  <th>性别</th>
                  <th>出生日期</th>
                  <th>联系电话</th>
                  <th>电子邮箱</th>
                  <th>地址</th>
                  <th>邮编</th>
                  <th>状态</th>
                  <th>操作</th>
              </thead>
              <c:forEach items="${page.pageContent}" var="user">
                  <tr>
                      <td>${user.userName}</td>
                      <td>${user.userPwd}</td>
                      <td>${user.realName}</td>
                      <td>
                          <c:if test="${user.sex==0}">
                              男
                          </c:if>
                          <c:if test="${user.sex==1}">
                              女
                          </c:if>
                      </td>
                      <td>${user.birthday}</td>
                      <td>${user.phoneCode}</td>
                      <td>${user.email}</td>
                      <td>${user.address}</td>
                      <td>${user.zipCode}</td>
                      <td>
                          <c:choose>
                              <c:when test="${user.formal==0}">
                                  未冻结
                              </c:when>
                              <c:when test="${user.formal==1}">
                                  冻结
                              </c:when>
                          </c:choose>
                      </td>
                      <td>
                          <button onclick="mend('${user.userName}');">修改</button>
                          <button onclick="del('${user.userName}');">删除</button>
                          <c:choose>
                              <c:when test="${user.formal==0}">
                                  <button class="control_button" onclick="setStatus('${user.userName}','1');">冻结</button>
                              </c:when>
                              <c:when test="${user.formal==1}">
                                  <button class="control_button" onclick="setStatus('${user.userName}','0');">解冻</button>
                              </c:when>
                          </c:choose>
                      </td>
                  </tr>
              </c:forEach>
          </table>
      </div>
      <br/>
	  <div class="page_infos">
	         共${page.totalRecNum}条, 当前显示${page.startIndex}-${page.endIndex}条, 第${page.pageNo}/${page.totalPageNum}页
	        |
	        <c:if test="${page.pageNo>1}">
	             <span class="linkspan" onclick="doQuery(1)">首页</span>&nbsp;
	        </c:if>
	        <c:if test="${page.prePage}">
	             <span class="linkspan" onclick="doQuery(${page.pageNo-1})">上一页</span>&nbsp;
	        </c:if>
	        <c:if test="${page.nextPage}">
	             <span class="linkspan" onclick="doQuery(${page.pageNo+1})">下一页</span>&nbsp;
	        </c:if>
	        <c:if test="${page.pageNo!=page.totalPageNum}">
	             <span class="linkspan" onclick="doQuery(${page.totalPageNum})">末页</span>&nbsp;
	        </c:if>
	        |
	            到<input type="text" id="pageNo" size=4 style="text-align:right;" onkeypress="onlynumber();" /> 页
	        <button onclick="doQuery2();">跳 转</button>		           	           	              
	  </div>
    
      <c:if test="${empty page.pageContent}">
        <div class="no_found" style="font-color:red">
          未查找到您所需的信息，请重新查询！
        </div>
      </c:if>
  </body>
</html>
